<template>
    <!-- <div id="index" ref="appRef" class="index_home" :class="{ pageisScale: isScale }"> -->
    <ScaleScreen
        :width="screenWidth"
        :height="screenHeight"
        class="scale-wrap"
        :selfAdaption="$store.state.setting.isScale"
    >
        <div class="bg">
            <dv-loading v-if="loading">Loading...</dv-loading>
            <div v-else class="host-body">
                <!-- 头部 s -->
                <div class="d-flex jc-center title_wrap">
                    <div class="zuojuxing"></div>
                    <div class="youjuxing"></div>
                    <div class="guang"></div>
                    <div class="d-flex jc-center">
                        <div class="title">
                            <span class="title-text"
                                >山西万鸿项目升级管理平台</span
                            >
                        </div>
                    </div>
                    <div class="timers">
                        <div class="loginOut" @click="loginOut">退出登录</div>

                        {{ dateYear }} {{ dateWeek }} {{ dateDay }}
                        <!-- <i
              class="blq-icon-shezhi02"
              style="margin-left: 10px"
              @click="showSetting"
            ></i> -->
                    </div>
                </div>
                <!-- 头部 e-->
                <!-- 内容  s-->
                <router-view></router-view>
                <!-- 内容 e -->
            </div>
        </div>
        <Setting ref="setting" />
    </ScaleScreen>
    <!-- </div> -->
</template>

<script>
import { formatTime } from '../utils/index.js'
import Setting from './setting.vue'
import ScaleScreen from '@/components/scale-screen/scale-screen.vue'
import { MessageBox } from 'element-ui'
export default {
    components: { Setting, ScaleScreen },
    data() {
        return {
            timing: null,
            loading: true,
            dateDay: null,
            dateYear: null,
            dateWeek: null,
            weekday: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
            screenWidth:"",
            screenHeight:""
        }
    },
    filters: {
        numsFilter(msg) {
            return msg || 0
        }
    },
    computed: {},
    created() {
        this.screenWidth = window.screen.width;
        this.screenHeight = window.screen.height;
        if(this.screenWidth<=1400){
            this.screenWidth = 1600;
            this.screenHeight = 900;
        }
    },
    mounted() {
        this.timeFn()
        this.cancelLoading()
    },
    beforeDestroy() {
        clearInterval(this.timing)
    },
    methods: {
        loginOut() {
            MessageBox.confirm('是否要退出升级系统？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                window.localStorage.removeItem('token')
                this.$router.push('/login')
            })
        },
        showSetting() {
            this.$refs.setting.init()
        },
        timeFn() {
            this.timing = setInterval(() => {
                this.dateDay = formatTime(new Date(), 'HH: mm: ss')
                this.dateYear = formatTime(new Date(), 'yyyy-MM-dd')
                this.dateWeek = this.weekday[new Date().getDay()]
            }, 1000)
        },
        cancelLoading() {
            let timer = setTimeout(() => {
                this.loading = false
                clearTimeout(timer)
            }, 500)
        }
    }
}
</script>

<style lang="scss">
@import './home.scss';
.loginOut {
    margin-right: 20px;
    cursor: pointer;
    padding: 8px 10px;
    background: #10457e;
    border-radius: 20px;
    // font-size: 14px;
}
</style>
